package util.webSearch;

import java.util.Enumeration;
import java.util.Hashtable;


/**
 * 
 * @author sergio
 *
 */
public class DeliciousURLInfo {

	/**
	 * @param args
	 */

	private String url = null; // url of the web resource
	private Long total_posts = null; // total number of entries in delicious -visible-
	private String title = null; // title of the web resource (Website)
	
	
	
	
	private Hashtable<String, Long> frequent_tags = new Hashtable<String, Long>(); // contains pairs <tag, frequency> 

	private String hash = null; //md5 identifier

	public String getHash() {
		return hash;
	}

	public void setHash(String hash) {
		this.hash = hash;
	}



	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Long getTotal_posts() {
		return total_posts;
	}

	public void setTotal_posts(Long totalPosts) {
		total_posts = totalPosts;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Hashtable<String, Long> getFrequent_tags() {
		return frequent_tags;
	}

	public void setFrequent_tags(Hashtable<String, Long> frequentTags) {
		frequent_tags = frequentTags;
	}

	
	public String getTagsRaw(int min_freq) {

		String t = "";

		if (frequent_tags != null) {
			Enumeration<String> keys = frequent_tags.keys();

			while (keys.hasMoreElements()) {

				String key = keys.nextElement();

				if (frequent_tags.get(key) > min_freq) {
					t = t + key + " ";

				}

			}

		} else {

			return null;
		}

		if (t != null && t.length() > 1) {
			return t.substring(0, t.length() - 1);
		}
		if (t.equals(""))
			return null;
		return t;

	}
	public String toString() {

		String string = "";

		string += url + "\n";
		string += title + "\n";
		string += total_posts + "\n";

		Enumeration<String> keys = frequent_tags.keys();

		while (keys.hasMoreElements()) {
			String key = keys.nextElement();
			string += key + "\t" + frequent_tags.get(key) + "\n";

		}

		return string;

	}
	
	
	public String getTagsFrequency() {

		String string = "";

		

		Enumeration<String> keys = frequent_tags.keys();

		while (keys.hasMoreElements()) {
			String key = keys.nextElement();
			string += key + " " + frequent_tags.get(key) + "\t";

		}

		return string;

	}

}
